package com.renchunlin.looerpager

import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.renchunlin.looerpager.adapter.CarouselPagerAdapter
import com.renchunlin.looerpager.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {
    private val carouselPagerAdapter by lazy {
        CarouselPagerAdapter(listPic)
    }
    private val listPic =
        listOf(R.drawable.pic1, R.drawable.pic2, R.drawable.pic3, R.drawable.pic4)
    private lateinit var binding: ActivityMainBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)

        initView()
    }

    private fun initView() {
        binding.viewPager.adapter = carouselPagerAdapter
        //设置到一个中间位置
        binding.viewPager.currentItem = Int.MAX_VALUE / 2 + 1
        Log.i("chen", "int的最大数:${Int.MAX_VALUE / 2}")
    }
}